import Vue from 'vue'
import Router from 'vue-router'
import store from './store'
// import Menubar from './components/common/Menubar'
// import Topbar from './components/common/Topbar'

Vue.use(Router)
let routes = [
    {
        path: '/',
        name: 'Login',
        components: {
            default: () =>
                import ('./views/Login')
        },
    },
    //概览
    {
        path: '/index',
        name: 'index',
        components: {
            content: () =>
                import ('./views/Home/index')
        },
        meta: { requiresAuth: true }
    },
    //节点信息
    {
        path: '/physical',
        name: 'physical',
        components: {
            content: () =>
                import ('./views/physical/physical')
        },
        meta: { requiresAuth: true }
    },
    //节点信息详情
    {
        path: '/phyList',
        name: 'phyList',
        components: {
            content: () =>
                import ('./components/physical/phyList')
        },
        meta: { requiresAuth: true }
    },
    //物理资源概况
    {
        path: '/resources',
        name: 'resources',
        components: {
            content: () =>
                import ('./views/physical/resources')
        },
        meta: { requiresAuth: true }
    },
    //网络拓扑
    {
        path: '/topology',
        name: 'topology',
        components: {
            content: () =>
                // import ('./views/physical/topology')
                import ('./views/physical/NetMainPage.vue')
        },
        meta: { requiresAuth: true }
    },
    //存储管理概况
    {
        path: '/overview',
        name: 'overview',
        components: {
            content: () =>
                import ('./views/storage_mgr/overview/overview')
        },
        meta: { requiresAuth: true }
    },
    //存储管理概况
    {
        path: '/BlockDetail',
        name: 'BlockDetail',
        components: {
            content: () =>
                import ('./views/storage_mgr/osd/BlockDetail')
        },
        meta: { requiresAuth: false }
    },
    //网络磁盘
    {
        path: '/block',
        name: 'block',
        components: {
            content: () =>
                import ('./views/storage_mgr/osd/block')
        },
        meta: { requiresAuth: true }
    },
    //存储池
    {
        path: '/pool',
        name: 'pool',
        components: {
            content: () =>
                import ('./views/storage_mgr/pool/pool')
        },
        meta: { requiresAuth: false }
    },
    //文件系统
    {
        path: '/fsview',
        name: 'fsview',
        components: {
            content: () =>
                import ('./views/storage_mgr/filesystem/fsview')
        },
        meta: { requiresAuth: true }
    },
    {
        path: '/snapshotConfig',
        name: 'snapshotConfig',
        components: {
            content: () =>
                import ('./views/storage_mgr/filesystem/directory/snapshotConfig')
        },
        meta: { requiresAuth: false }
    },
    //对象存储
    {
        path: '/objview',
        name: 'objview',
        components: {
            content: () =>
                import ('./views/storage_mgr/object/objview')
        },
        meta: { requiresAuth: true }
    },
    //文件共享
    {
        path: '/filesharing',
        name: 'filesharing',
        components: {
            content: () =>
                import ('./views/storage_mgr/filesharing/filesharing')
        },
        meta: { requiresAuth: true }
    },
    //网关管理
    // {
    //     path: '/gatewayManage',
    //     name: 'GatewayManage',
    //     components: {
    //         content: () =>
    //             import ('./views/storage_mgr/gatewayManage/GatewayManage.vue')
    //     },
    //     meta: { requiresAuth: true }
    // },
    //集群检查
    {
        path: '/cluster',
        name: 'cluster',
        components: {
            content: () =>
                import ('./views/operation/cluster/cluster')
        },
        meta: { requiresAuth: true }
    },
    //扩容、缩容
    // {
    //     path: '/capacity',
    //     name: 'capacity',
    //     components: {
    //         content: () =>
    //             import ('./views/operation/capacity/expend')
    //     },
    //     meta: { requiresAuth: true }
    // },
    //osd磁盘管理
    {
        path: '/diskmgr',
        name: 'diskmgr',
        components: {
            content: () =>
                import ('./views/operation/osddisk/diskmgr')
        },
        meta: { requiresAuth: true }
    },
    //集群调控
    {
        path: '/regular',
        name: 'regular',
        components: {
            content: () =>
                import ('./views/operation/regulartion/regular')
        },
        meta: { requiresAuth: true }
    },
    //纠删码配置
    {
        path: '/erasure',
        name: 'erasure',
        components: {
            content: () =>
                import ('./views/operation/erasure/erasure')
        },
        meta: { requiresAuth: true }
    },
    //磁盘检测
    {
        path: '/diskcheck',
        name: 'DiskCheck',
        components: {
            content: () =>
                import ('./views/operation/disk_check/DiskCheck.vue')
        },
        meta: { requiresAuth: true }
    },
    //日志管理
    {
        path: '/Log',
        name: 'Log',
        components: {
            content: () =>
                import ('./views/operation/log_manage/Log.vue')
        },
        meta: { requiresAuth: true }
    },
       // Oauth2身份认证管理
    {
        path: '/OAuth',
        name: 'OAuth',
        components: {
            content: () =>
                import ('./views/manage/OAuth')
        },
        meta: { requiresAuth: false }
    },
    // {
    //     path: '/per_config',
    //     name: 'per_config',
    //     components: {
    //         content: () =>
    //             import ('./views/operation/per_config/per_config')
    //     },
    //     meta: { requiresAuth: true }
    // },
    //用户管理
    {
        path: '/usermanage',
        name: 'usermanage',
        components: {
            content: () =>
                import ('./views/manage/usermanage')
        },
        meta: { requiresAuth: true }
    },
    // Oauth2身份认证管理
    {
        path: '/OAuth',
        name: 'OAuth',
        components: {
            content: () =>
                import ('./views/manage/OAuth')
        },
        meta: { requiresAuth: true }
    },
    // 认证域管理
    {
        path: '/authentication',
        name: 'authentication',
        components: {
            content: () =>
                import ('./views/manage/authentication/index.vue')
        },
        meta: { requiresAuth: true }
    },
    // 认证域管理详情
    {
        path: '/authenticationDetail',
        name: 'authenticationDetail',
        components: {
            content: () =>
                import ('./views/manage/authentication/detail.vue')
        },
        meta: { requiresAuth: false }
    },
    //机器
    {
        path: '/machine',
        name: 'machine',
        components: {
            content: () =>
                import ('./views/manage/machine')
        },
        meta: { requiresAuth: true }
    },
    //磁盘
    {
        path: '/diskmanage',
        name: 'diskmanage',
        components: {
            content: () =>
                import ('./views/manage/diskmanage')
        },
        meta: { requiresAuth: true }
    },
    //告警
    {
        path: '/alertmanage',
        name: 'alertmanage',
        components: {
            content: () =>
                import ('./views/manage/alertmanage')
        },
        meta: { requiresAuth: true }
    },
    // {
    //     path: '/log',
    //     name: 'log',
    //     components: {
    //         content: () =>
    //             import ('./views/manage/log')
    //     },
    //     meta: { requiresAuth: true }
    // },
    // 出厂前版权信息编辑
    // {
    //     path: '/Settings',
    //     name: 'Settings',
    //     components: {
    //         content: () =>
    //             import ('./components/common/Settings.vue')
    //     },
    //     meta: { requiresAuth: true }
    // },
    //信息收集
    // {
    //     path: '/collect',
    //     name: 'collect',
    //     components: {
    //         content: () =>
    //             import ('./views/operation/collect/collect.vue')
    //     },
    //     meta: { requiresAuth: true }
    // },
    {
        path: '/alertList',
        name: 'alertList',
        components: {
            content: () =>
                import ('./views/monitor/alertList.vue')
        },
        meta: { requiresAuth: true }
    },
    {
        path: '/alarmRule',
        name: 'alarmRule',
        components: {
            content: () =>
                import ('./views/monitor/alarmRule.vue')
        },
        meta: { requiresAuth: true }
    },
    {
        path: '/alarmChannel',
        name: 'alarmChannel',
        components: {
            content: () =>
                import ('./views/monitor/alarmChannel.vue')
        },
        // meta: { requiresAuth: true }
    
},


    {
        path: '/alarmConfig',
        name: 'alarmConfig',
        components: {
            content: () =>
                import ('./views/monitor/alarmConfig.vue')
        },
        meta: { requiresAuth: true }
    },
    //权限配置
    {
        path: '/authorityConfig',
        name: 'AuthorityConfig',
        components: {
            content: () =>
                import ('./views/authorityConfig/AuthorityConfig.vue')
        },
        meta: { requiresAuth: true }
    },
    //存储平台
    {
        path: '/store',
        name: 'store',
        components: {
            content: () =>
                import ('./views/data/store.vue')
        },
        meta: { requiresAuth: true }
    },
    //保护网关
    {
        path: '/gateway',
        name: 'gateway',
        components: {
            content: () =>
                import ('./views/data/gateway.vue')
        },
        meta: { requiresAuth: true }
    },
    //保护计划
    {
        path: '/protect_strategy',
        name: 'protect_strategy',
        components: {
            content: () =>
                import ('./views/data/strategy.vue')
        },
        meta: { requiresAuth: true }
    },
    {
        path: '/protect_task',
        name: 'protect_task',
        components: {
            content: () =>
                import ('./views/data/task.vue')
        },
        meta: { requiresAuth: true }
    },
    {
        path: '/copy_relationship',
        name: 'copy_relationship',
        components: {
            content: () =>
                import('./views/data/relationship.vue')
        },
        // meta: { requiresAuth: true }
    },
    {
        path: '/shareDetail',
        name: 'shareDetail',
        components: {
            content: () =>
                import ('./views/storage_mgr/filesystem/share/SMBDetail.vue')
        },
        meta: { requiresAuth: false }
    },
    {
        path: '/createShare',
        name: 'createShare',
        components: {
            content: () =>
                import ('./views/storage_mgr/filesystem/share/createShare.vue')
        },
        meta: { requiresAuth: false }
    },
    {
        path: '/modifyShare',
        name: 'modifyShare',
        components: {
            content: () =>
                import ('./views/storage_mgr/filesystem/share/modifyShare.vue')
        },
        meta: { requiresAuth: false }
    },
    {
        path: '/strategy_create',
        name: 'strategyCreate',
        components: {
            content: () =>
                import ('./views/data/strategy/fileCreate.vue')
        },
        meta: { requiresAuth: false }
    },
    {
        path: '/strategy_edit',
        name: 'strategyEdit',
        components: {
            content: () =>
                import ('./views/data/strategy/fileEdit.vue')
        },
        meta: { requiresAuth: false }
    },
    {
        path: '/protect_task/detail',
        name: 'taskDetail',
        components: {
            content: () =>
                import ('./views/data/task/taskDetail.vue')
        },
        meta: { requiresAuth: false }
    },
    {
        path: '/createQuota',
        name: 'createQuota',
        components: {
            content: () =>
                import ('./views/storage_mgr/filesystem/quota/createQuota.vue')
        },
        meta: { requiresAuth: false }
    },
    {
        path: '/modifyQuota',
        name: 'modifyQuota',
        components: {
            content: () =>
                import ('./views/storage_mgr/filesystem/quota/modifyQuota.vue')
        },
        meta: { requiresAuth: false }
    },
    {
        path: '/quotaDetail',
        name: 'quotaDetail',
        components: {
            content: () =>
                import ('./views/storage_mgr/filesystem/quota/quotaDetail.vue')
        },
        meta: { requiresAuth: false }
    },
    {
        path: '/nfs',
        name: 'nfs',
        components: {
            content: () =>
                import ('./components/storage_mgr/filesharing/file_nfs.vue')
        },
        meta: { requiresAuth: false }
    },
    // 任务管理
    {
        path: '/task',
        name: 'task',
        components: {
            content: () =>
                import ('./views/operation/task')
        },
        meta: { requiresAuth: false }
    },
    //集群接入平台
    {
        path: '/cluster_access',
        name: 'cluster_access',
        components: {
            content: () =>
                import('./views/systemSettings/clusterAccess.vue')
        },
    },
    //数据保护设置
    {
        path: '/data_protect',
        name: 'data_protect',
        components: {
            content: () =>
                import('./views/systemSettings/dataProtect.vue')
        },
    },
    //认证服务
    {
        path: '/certification_service',
        name: 'certification_service',
        components: {
            content: () =>
                import('./views/systemSettings/certificationService.vue')
        },
    },
    //生态集成
    {
        path: '/cloud_native',
        name: 'cloud_native',
        components: {
            content: () =>
                import ('./views/ecologicalIntegration/cloudnative.vue')
        },
        meta: { requiresAuth: false }
    },
    {
        path: '/test',
        name: 'Test',
        components: {
            content: () =>
                import ('./views/Test.vue')
        },
        meta: { requiresAuth: false }
    },

]

const router =  new Router({
    // mode: 'history',
    base: process.env.BASE_URL,
    routes
})

router.beforeEach((to, from, next) => {
    const authToken = localStorage.getItem('authToken');
    // const getTitle = JSON.parse(store.state.commonModule.oemConfig)
    // const title = getTitle.softwareName
    // document.title = title
    if (!authToken && to.path !== '/') {
        next('/');
    } else if(authToken && to.path == '/') {
        next('/index')
    } else {
        next();
    }
})

export default router;